import { http } from '@/utils/http';
import { getWxUserId } from '@/utils/auth';
export const getArticleDetail = (articleId : string) => {
	return http<AnyObj>({
		method: 'GET',
		url: `/wx/article/${articleId}`
	});
}


export const getArticleList = (data : AnyObj) => {
	return http<AnyObj[]>({
		method: 'GET',
		url: `/wx/article/listByCategory`,
		data
	});
}


export const saveArticleComment = (data : AnyObj) => {
	const wxUserId = getWxUserId();
	return http<AnyObj[]>({
		method: 'POST',
		url: `/wx/article/comment`,
		data: {
			...data,
			wxUserId
		}
	});
}

export const saveArticleUpvote = (articleId : string) => {
	const wxUserId = getWxUserId();
	return http<AnyObj[]>({
		method: 'POST',
		url: `/wx/article/upvote`,
		data: {
			articleId,
			wxUserId
		}
	});
}

export const cancelArticleUpvote = (articleId : string) => {
	const wxUserId = getWxUserId();
	return http<AnyObj[]>({
		method: 'POST',
		url: `/wx/article/cancelUpvote`,
		data: {
			articleId,
			wxUserId
		}
	});
}